<?php
header('content-type:text/html;charset=utf-8');
session_start();
require 'config.php';
error_reporting(5);
error_reporting(E_ALL & ~E_NOTICE);
error_reporting(0);

$username=$_POST['username'];
$name=$_POST['name'];
$tel=$_POST['tel'];
$email=$_POST['uemail'];
$address=$_POST['uaddress'];
$goods_fenlei=$_POST['hsfl'];
// $picture_leibie=$_POST['picture'];
// $pub_time=$_POST['pub_time'];

// $sql="SELECT * FROM school WHERE `huishou`='$huishou'";
// 图片上传


$filename = $_FILES['file']['name'];
$tmp_name = $_FILES['file']['tmp_name'];

//将服务器上的临时文件移动到指定目录下
// var_dump($filename);
//使用该方法move_uploaded_file($tmp_name , $destination)

move_uploaded_file($tmp_name , "D:phpstudy_pro/WWW/school/images/huishou/$goods_fenlei/".$filename);


 //引入数据库
// include_once('config.php');
// $link=create_connection();
// $res=db_getOne($link,'school');
// $sql="insert into huishou values('{$username}','{$name}','{tel}',{$email}','{$address}','{hsgood}')";
// execute_sql($link,'school',$sql);

// header('Refresh:2;url=index.php');
// echo '提交成功';
// die();
// $query="INSERT INTO users(`uemail`,`upassword`,`uname`,`uphone`) VALUES('$email','$pword','$name','$phone')";


$pub_time=Date('Y-m-d H:i:s');
include_once('dbtools.inc.php');
$link=create_connection();
$query="INSERT INTO huishou (`username`,`name`,`tel`,`uemail`,`address`,`goods_fenlei`,`pub_time`,`picture`)
VALUES ('$username','$name','$tel','$email','$address','$goods_fenlei','$pub_time','".$filename."')";
// $sql="insert into huishou (username='{$username}',name={$name},tel={$tel},email='{$email}',address={$address},hsgood={$hsgood})";
$res=execute_sql($link,'school',$query);
header('Refresh:2;url=form_hs.php');
echo '提交成功，请等待工作人员验收！';
	die();



// $query="INSERT INTO huishou(`username`,`name`,`tel`,`uemail`,'uaddress','hsgood') VALUES('$username','$name','$tel','$email','$address','$hsgood')";
// $result = mysqli_query($config,$query)or die("error:".mysqli_error($conn));
// echo $query;
// if ($result) {
// 	echo ('<script type="text/javascript">alert("提交成功");
// 		window.location.href = "index.php";
// 		</script>');
// }else{
// 	echo('<script type="text/javascript">alert("提交失败");
// 		</script>');
// }




